package com.wangnan.currentactivity.extract;

import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;

import com.wangnan.currentactivity.BaseApplication;
import com.wangnan.currentactivity.Dao.BillList;
import com.wangnan.currentactivity.ui.UserBillBean;

/*
 * Package    :com.wangnan.currentactivity.extract
 * ClassName  :RecycleDetailsExtract
 * Description:
 * Data       :2021/2/27/027 10:09
 */
public class RecycleDetailsExtract extends ExtractPublic{
	@Override
	public void recycleDetails(AccessibilityNodeInfo info,String type) {
		if (info.getChildCount() == 0 && info.getText() != null) {
			if (info.getText().toString().replace(" ","").length() >= 2){
				BaseApplication.userDetailsList.add(new UserBillBean(info.getText().toString(),BaseApplication.A++));
				Log.e("zzh数据长度大于等于2", type+"Text："+ BaseApplication.userDetailsList.get(BaseApplication.A-1).getName()+"------"+
						+BaseApplication.userDetailsList.get(BaseApplication.A-1).getSerialNumber());
			}
		} else {
			for (int i = 0; i < info.getChildCount(); i++) {
				if(info.getChild(i)!=null){
					recycleDetails(info.getChild(i),type);
				}
			}
		}
	}

	/**
	 * 写入数据库
	 */
	@Override
	public	void writeToTheDatabaseRoom(BillList billList) {
		BaseApplication.billListViewModel.insertBillLists(billList);
	}
}